<template>
  <div style="width:100%;height:100vh;background:#f5f5f5;">
    <mt-header fixed title="提现" style="background:#fff;color:#000;">
      <router-link to="/" slot="left">
        <mt-button icon="back"></mt-button>
      </router-link>
      <!-- <span slot="right">提款记录</span> -->
    </mt-header>
    <div style="width:100%;height:1rem;"></div>
    <div class="with_content">
      <p>账户余额</p>
      <p>{{account}}</p>
    </div>
    <div class="with_center">
      <div class="with_input">
        <span>提款金额</span>
        <input  v-model="param.fee" type="text" placeholder="请输入提款金额">
        <span>元</span>
      </div>
      <div class="with_input">
        <span>提款银行卡</span>
        <select>
          <option value="volvo">{{bankNo}}</option>
          
        </select>
        <span></span>
      </div>
    </div>
    <div class="ver_button">
      <button  @click="withdraws()">提款</button>
    </div>
    <div class="tran_text" style>
      <span>每日提现次数限两次</span>
    </div>
    <div class="tran_text" style>
      <span>提现处理时间为 09:00-20:00</span>
    </div>
    <div class="tran_text" style>
      <span>到账时间以银行为准，节假日延后处理</span>
    </div>
  </div>
</template>

<script>
export default {
    data() {
    return {
      param: {
        fee: ""
      },
      bankNo: "",
      account:''
    };
  },
  mounted() {
    this.withdraw();
  },
  methods: {
    back() {
      this.$router.go(-1);
    },
    withdraws() {
      var that = this;
      if (that.param.fee == "") {
        return that.$message.error("请输入提现金额！");
      }
      if (that.bankNo == "") {
        that.$router.push({ path: "Authentication" });
        return that.$message.error("请先前往绑定银行卡！");
      }
      that
        .$http({
          //调用接口
          method: "POST",
          headers: {
            "Content-Type": "application/json; charset=UTF-8"
          },
          data: that.param,
          url: that.$serverUrl + "withdraw"
        })
        .then(
          res => {
            this.param = res.data.data;
           
               if (res.data.msg == "success") {
              that.$message.success("提现成功！");
              that.$router.go(-1);
            } else {
              that.$message.error(res.data.msg);
            }
          },
          function(error) {}
        );
    },
    withdraw() {
      var that = this;
      that
        .$http({
          //调用接口
          method: "GET",
          headers: {
            "Content-Type": "application/json; charset=UTF-8"
          },
          //   data:that.list,
          url: that.$serverUrl + "user/bank"
        })
        .then(
          res => {
            this.bankNo = res.data.data.bankNo;
            this.account = res.data.data.account
            // console.log(res.data.data)
          },
          function(error) {}
        );
    },
  }
};
</script>
<style scoped>
.with_content {
  width: 100%;
  height: 2rem;
  border-bottom: 1px solid #e8e8e8;
  font-size: 0.35rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  letter-spacing: 1px;
  color: #666;
  background: #fff;
}
.with_content p {
  padding: 0.1rem 0;
}
.with_content p:last-child {
  color: #ff7500;
  font-size: 0.6rem;
}
.with_center {
  width: 100%;
  height: 4rem;
  background: #fff;
  margin-top: 0.2rem;
  border-top: 1px solid #e8e8e8;
}
.with_input {
  width: 90%;
  height: 2rem;
  margin: 0 auto;
  display: flex;
  justify-content: space-around;
  align-items: center;
  border-bottom: 1px solid #e8e8e8;
 
}
.with_input input,
.with_input select {
  width: 60%;
  height: 1rem;
  border: none;
  outline: none;
  letter-spacing: 1px;
   background: #fff;
}
.with_input span {
  font-size: 0.4rem;
  letter-spacing: 1px;
}
.with_bank {
  width: 100%;
  height: 2rem;
  background: red;
}
.ver_button {
  width: 100%;
  height: 2rem;
  display: flex;
  justify-content: center;
  align-items: center;
}
.ver_button button {
  width: 80%;
  height: 1.2rem;
  background: #b3262c;
  color: #fff;
  font-size: 0.4rem;
  letter-spacing: 2px;
  border: none;
  border-radius: 8px;
}
.tran_text {
  width: 100%;
  height: 0.6rem;
  line-height: 0.8rem;
  text-align: center;
  letter-spacing: 1px;
  font-size: 0.35rem;
  color: #a5a5a5;
}
</style>
